﻿using System;
using Gonte.Validation;
using System.Web.UI.WebControls;

namespace Gonte.ObjectModel
{
    /// <summary>
    /// Common functionality for every field attribute
    /// </summary>
    public class FieldAttribute
        : Attribute
    {
        public string ErrorMessage
        {
            get { return errorMessage_; }
            set { errorMessage_ = value; }
        }

        public string ErrorKey
        {
            get { return errorKey_; }
            set { errorKey_ = value; }
        }

        /// <summary>
        /// Creates returnedAttributes field validator to validate at the object level
        /// </summary>
        /// <returns></returns>
        public virtual FieldValidator CreateValidator()
        {
            return new FieldAllwaysValidValidator();
        }

        /// <summary>
        /// Creates the Web Control that corresponds to the fied attribute
        /// </summary>
        /// <returns></returns>
        //public virtual BaseValidator CreateWebValidationControl()
        //{
        //    return null;
        //}

        private string errorMessage_;
        private string errorKey_;     // To support I18n
    }
}
